#ifndef SC_PACKET_SINK_H
#define SC_PACKET_SINK_H

#include "common.h"

#include <assert.h>
#include <stdbool.h>
#include <libavcodec/avcodec.h>

/**
 * Packet sink trait. 视频包接收特性
 * 接收AVPackets需要实现此特性
 * 此种定义类似java语言中的接口，需要在其他的地方有具体实现
 * Component able to receive AVPackets should implement this trait.
 */
struct sc_packet_sink {
    const struct sc_packet_sink_ops *ops;
};

/* 视频包接收回调函数 */
struct sc_packet_sink_ops {
    /* The codec context is valid until the sink is closed */

    /*
    打开
    @param sink
    @param codec 解码器
    @return
    */    
    bool (*open)(struct sc_packet_sink *sink, AVCodecContext *ctx);

    /*
    关闭
    @param sink
    */
    void (*close)(struct sc_packet_sink *sink);

    /*
    推送
    @param sink
    @param codec 解码器
    @return
    */
    bool (*push)(struct sc_packet_sink *sink, const AVPacket *packet);

    /*/
     * Called when the input stream has been disabled at runtime.
     *
     * If it is called, then open(), close() and push() will never be called.
     *
     * It is useful to notify the recorder that the requested audio stream has
     * finally been disabled because the device could not capture it.
     */
    void (*disable)(struct sc_packet_sink *sink);
};

#endif
